package com.ict.web.dto;

import com.ict.common.utils.DateUtils;
import com.ict.common.utils.bean.BeanUtils;
import com.ict.common.utils.uuid.IdUtils;
import com.ict.web.domain.PerformanceIndicators;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;


/**
 * 指标公告对象 yzq_performance_indicators
 *
 * @author xss
 * @date 2022-02-17
 */
@Data
public class InsertPerIndicatorsDto {
    @ApiModelProperty(value = "指标名称")
    private String indicatorsName;

    @ApiModelProperty(value = "指标规则")
    @Valid
    private List<InsertPerformanceRuleDto> performanceRules;

    @ApiModelProperty(value = "指标权重{保留两位小数}")
    private Double indicatorsWeight;



    public static PerformanceIndicators of(InsertPerIndicatorsDto addDto){
        PerformanceIndicators bean = new PerformanceIndicators();
        BeanUtils.copyProperties(addDto,bean);
        //设置指标id
        bean.setIndicatorsId(IdUtils.snowId());
        //设置创建时间和更新时间
        bean.setCreateTime(DateUtils.getNowDate());
        bean.setUpdateTime(DateUtils.getNowDate());
        //设置删除状态
        bean.setDelFlag(PerformanceIndicators.DELETE_STATUS_NORMAL);

        return bean;
    }
}
